/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.adama.entite.modele;

import java.io.Serializable;

import java.math.BigDecimal;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.OrderBy;

/**
 *
 * @author mini-john
 */
@Entity
@Table(uniqueConstraints = @UniqueConstraint(name = "nomExistModelPaie", columnNames = {"nom"}))
public class ModelePaie implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "modelpaie_sequence")
    @SequenceGenerator(name = "modelpaie_sequence", sequenceName = "modelpaie_sequence")
    private Long id;

    private String nom;

    BigDecimal assietteCotisation;

    @OneToMany(mappedBy = "modelPaie", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @OrderBy(clause = "positionBulletin")
    private List<LigneBulletinPaieModele> ligneBulletinPaieModele;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public BigDecimal getAssietteCotisation() {
        return assietteCotisation;
    }

    public void setAssietteCotisation(BigDecimal assietteCotisation) {
        this.assietteCotisation = assietteCotisation;
    }

    public List<LigneBulletinPaieModele> getLigneBulletinPaieModele() {
        return ligneBulletinPaieModele;
    }

    public void setLigneBulletinPaieModele(List<LigneBulletinPaieModele> ligneBulletinPaieModele) {
        this.ligneBulletinPaieModele = ligneBulletinPaieModele;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ModelePaie)) {
            return false;
        }
        ModelePaie other = (ModelePaie) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.adama.entite.modele.ModeleFacture[ id=" + id + " ]";
    }

}
